package org.zecontech.plantvszombie.init;

import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import org.zecontech.plantvszombie.PlantVsZombieMod;
import org.zecontech.plantvszombie.entity.CherryBomb;
import org.zecontech.plantvszombie.entity.SunFlower;
import org.zecontech.plantvszombie.util.Helpers;

public class ModEntities {

    public static final EntityType<SunFlower> SUN_FLOWER =
            register("sun_flower", SunFlower::new, 0.5F, 0.8F);
    public static final EntityType<CherryBomb> CHERRY_BOMB =
            register("cherry_bomb", CherryBomb::new, 0.3F, 0.6F);

    public static <T extends Entity> EntityType<T> register(String name, EntityType.EntityFactory<T> entityFactory, float width, float height) {
        return Registry.register(BuiltInRegistries.ENTITY_TYPE, Helpers.identifier(name),
                EntityType.Builder.of(entityFactory, MobCategory.CREATURE).sized(width, height)
                        .clientTrackingRange(64).updateInterval(3)
                        .build(ResourceKey.create(Registries.ENTITY_TYPE, Helpers.identifier(name))));
    }

    public static void register() {
        PlantVsZombieMod.LOGGER.info("Registered entities for " + PlantVsZombieMod.MOD_ID);
    }
}
